package com.ruowei.modules.webSocket.domain;

import com.ruowei.common.json.MapStringConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import com.ruowei.modules.webSocket.domain.enumeration.*;

import javax.persistence.*;

import java.io.Serializable;
import java.time.Instant;
import java.util.Map;


/**
 * 消息表
 */
@ApiModel(description = "消息表")
@Entity
@Table(name = "message")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Message implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 消息编码
     */
    @ApiModelProperty(value = "消息编码")
    @Column(name = "message_code")
    private String messageCode;

    /**
     * 发送方类型
     */
    @ApiModelProperty(value = "发送方类型")
    @Enumerated(EnumType.STRING)
    @Column(name = "sender_type")
    private SenderType senderType;

    /**
     * 发送人编号
     */
    @ApiModelProperty(value = "发送人编号")
    @Column(name = "sender_code")
    private String senderCode;

    /**
     * 接收方编号
     */
    @ApiModelProperty(value = "接收方编号")
    @Column(name = "receiver_code")
    private String receiverCode;

    /**
     * 消息类型
     */
    @ApiModelProperty(value = "消息类型")
    @Enumerated(EnumType.STRING)
    @Column(name = "message_type")
    private MessageType messageType;

    /**
     * 是否跳转页面
     */
    @ApiModelProperty(value = "是否跳转页面")
    @Column(name = "jump_page")
    private Boolean jumpPage;

    /**
     * 消息标题
     */
    @ApiModelProperty(value = "消息标题")
    @Column(name = "title")
    private String title;

    /**
     * 消息内容
     */
    @ApiModelProperty(value = "消息内容")
    @Lob
    @Column(name = "content")
    private String content;

    /**
     * 自定义消息体
     */
    @Lob
    @ApiModelProperty(value = "自定义消息体")
    @Column(name = "customMessage")
    @Convert(converter = MapStringConverter.class)
    private Map<String, String> customMessage;

    /**
     * 消息创建时间
     */
    @ApiModelProperty(value = "消息创建时间")
    @Column(name = "create_time")
    private Instant createTime;

    /**
     * 是否已读
     */
    @ApiModelProperty(value = "是否已读")
    @Column(name = "jhi_read")
    private Boolean read;

    /**
     * 已读时间
     */
    @ApiModelProperty(value = "已读时间")
    @Column(name = "read_time")
    private Instant readTime;

    /**
     * 计划发送时间
     */
    @ApiModelProperty(value = "计划发送时间")
    @Column(name = "plan_send_time")
    private Instant planSendTime;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Instant getPlanSendTime() {
        return planSendTime;
    }

    public void setPlanSendTime(Instant planSendTime) {
        this.planSendTime = planSendTime;
    }

    public String getMessageCode() {
        return messageCode;
    }

    public Message messageCode(String messageCode) {
        this.messageCode = messageCode;
        return this;
    }

    public void setMessageCode(String messageCode) {
        this.messageCode = messageCode;
    }

    public SenderType getSenderType() {
        return senderType;
    }

    public Message senderType(SenderType senderType) {
        this.senderType = senderType;
        return this;
    }

    public void setSenderType(SenderType senderType) {
        this.senderType = senderType;
    }

    public String getSenderCode() {
        return senderCode;
    }

    public Message senderCode(String senderCode) {
        this.senderCode = senderCode;
        return this;
    }

    public void setSenderCode(String senderCode) {
        this.senderCode = senderCode;
    }

    public String getReceiverCode() {
        return receiverCode;
    }

    public Message receiverCode(String receiverCode) {
        this.receiverCode = receiverCode;
        return this;
    }

    public void setReceiverCode(String receiverCode) {
        this.receiverCode = receiverCode;
    }

    public MessageType getMessageType() {
        return messageType;
    }

    public Message messageType(MessageType messageType) {
        this.messageType = messageType;
        return this;
    }

    public void setMessageType(MessageType messageType) {
        this.messageType = messageType;
    }

    public Boolean isJumpPage() {
        return jumpPage;
    }

    public Message jumpPage(Boolean jumpPage) {
        this.jumpPage = jumpPage;
        return this;
    }

    public void setJumpPage(Boolean jumpPage) {
        this.jumpPage = jumpPage;
    }

    public String getTitle() {
        return title;
    }

    public Message title(String title) {
        this.title = title;
        return this;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public Message content(String content) {
        this.content = content;
        return this;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Map<String, String> getCustomMessage() {
        return customMessage;
    }

    public void setCustomMessage(Map<String, String> customMessage) {
        this.customMessage = customMessage;
    }

    public Instant getCreateTime() {
        return createTime;
    }

    public Message createTime(Instant createTime) {
        this.createTime = createTime;
        return this;
    }

    public void setCreateTime(Instant createTime) {
        this.createTime = createTime;
    }

    public Boolean isRead() {
        return read;
    }

    public Message read(Boolean read) {
        this.read = read;
        return this;
    }

    public void setRead(Boolean read) {
        this.read = read;
    }

    public Instant getReadTime() {
        return readTime;
    }

    public Message readTime(Instant readTime) {
        this.readTime = readTime;
        return this;
    }

    public void setReadTime(Instant readTime) {
        this.readTime = readTime;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Message)) {
            return false;
        }
        return id != null && id.equals(((Message) o).id);
    }

    @Override
    public int hashCode() {
        return 31;
    }

    @Override
    public String toString() {
        return "Message{" +
            "id=" + getId() +
            ", messageCode='" + getMessageCode() + "'" +
            ", senderType='" + getSenderType() + "'" +
            ", senderCode='" + getSenderCode() + "'" +
            ", receiverCode='" + getReceiverCode() + "'" +
            ", messageType='" + getMessageType() + "'" +
            ", jumpPage='" + isJumpPage() + "'" +
            ", title='" + getTitle() + "'" +
            ", content='" + getContent() + "'" +
            ", customMessage='" + getCustomMessage() + "'" +
            ", createTime='" + getCreateTime() + "'" +
            ", read='" + isRead() + "'" +
            ", readTime='" + getReadTime() + "'" +
            "}";
    }
}
